Routing

The Problem
===========

How do we get packets from A to B?

Assumptions
===========

Hosts
- have interfaces on to a subnet

Subnets
- each host on a subnet has the ability to communicate with any other

Routers
- hosts can have multiple interfaces
- put these on different subnets
- then machine can relay packets from hosts on one of its subnets
  to hosts on the other 

So:
- can view the network as an arbitrary topology of subnets connected
  by routers

High Level Solution
===================

Addresses
- first clue given by the problem: need to be able to name A and B
- need some way to identify the interfaces that the hosts have
- assign them a number, for now assume it can be assigned randomly
  (but doesn't have to be)

Routing Tables
- so once you've got things addressed a simple and obvious way to 
  think about things pops
- assume each node has a list of *all* the addresses,
  and where to send packets for that address

Router Behavior
- receive packet
- look at destination address
- figure out where to send it to (local, other node on subnet)
- send it there
- gets repeated until it gets to the destination

Hierarchical Addressing
=======================

Problem
- keeping a full table is too big (millions of nodes)
- perhaps possible for routers, but for end hosts!?

Aggregates
- provide a way to associate topologically-close groups of nodes
- within a group, nodes know the detailed location of hosts in the group
- outside of a group, nodes only know the way to the group
- basic unit of aggregation: the subnet, since all hosts on a subnet
  already sort-of know about each other
- other units: any cluster of subnets

Implementation
- prefixes
- that is, related addresses start with the same prefix
- "broad" routes for large groups of addresses will have short prefixes
- more specific routers for smaller groups will have longer prefixes
- not just a pure table lookup: now need to make "longest match"
- radix tree

Results
- nodes are *really* simple: 
  - need to know who they are
  - need to know what subnet they're on
  - everything else is just "out there", past a router on their subnet
- routers:
  - don't have to deal with every host
  - just subnets
  - or, groups of subnets i.e. "rest of the internet", "the company network"

IPv4 Addressing
===============





